package com.springboot.listener;

import com.springboot.event.LoginEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class LoginListener implements ApplicationListener<LoginEvent> {
    @Override
    @Async
    public void onApplicationEvent(LoginEvent event) {
        System.out.println(event.getSource()+":" +System.nanoTime() +" 登录成功");
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(event.getSource()+":" +System.nanoTime() +" 登录完成");

    }



}
